﻿using FirstFloor.ModernUI.Presentation;
using FirstFloor.ModernUI.Windows.Controls;
using LinnerToolkit.Desktop.ModernUI.Mvvm;
using LinnerToolkit.Desktop.ModernUI.Navigation;
using SimulationPTSystem.DAL;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace SimulationPTSystem.ViewModels
{
    public class ChengYuanTrainingRecPageViewModel : ModernViewModelBase
    {
        private ObservableCollection<ChengYuanTrainingRec> chengYuanTrainingRecs;
        private ChengYuanTrainingRec selectedChengYuanTrainingRec;

        public string ChengYuanCode { get; set; }

        public string ChengYuanName { get; set; }

        public ObservableCollection<ChengYuanTrainingRec> ChengYuanTrainingRecs { get => chengYuanTrainingRecs; set => Set(ref chengYuanTrainingRecs, value); }

        public ChengYuanTrainingRec SelectedChengYuanTrainingRec { get => selectedChengYuanTrainingRec; set => Set(ref selectedChengYuanTrainingRec, value); }

        public DateTime StartTime { get; set; }

        public DateTime EndTime { get; set; }

        public ICommand QueryCommand { get; }

        public ICommand DetailsCommand { get; }

        public ChengYuanTrainingRecPageViewModel(IModernNavigationService navigationService) : base(navigationService)
        {
            StartTime = EndTime = DateTime.Now;

            QueryCommand = new RelayCommand(async (obj) =>
            {
                ChengYuanTrainingRecs = new ObservableCollection<ChengYuanTrainingRec>(await SimulationPTDAL.GetChengYuanTrainingRecs(ChengYuanCode, ChengYuanName, StartTime, EndTime));
            });

            DetailsCommand = new RelayCommand((obj) =>
            {
                if (SelectedChengYuanTrainingRec == null)
                {
                    ModernDialog.ShowMessage("请先选择要查看的人员报告", string.Empty, System.Windows.MessageBoxButton.OK);
                    return;
                }

                // 查看报告
            });
        }
    }
}
